package com.auxgroup.smarthome.repo;

import com.auxgroup.smarthome.entity.SysMessageEntity;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.transaction.annotation.Transactional;

import java.util.Collection;

/**
 * Created by fju on 2017/8/7.
 */
public interface SysMessageEntityRepo  extends GenericDao<SysMessageEntity,String> {

    @Query(value = "update SysMessageEntity se set se.trash = true where se.createdBy = ?1 ")
    @Modifying
    @Transactional
    int clearSysMessageByUserId(String userId);

    @Query(value = "update SysMessageEntity se set se.trash = true where se.sysMessageId in (:ids)")
    @Modifying
    @Transactional
    int deleteSysMessageByUserId(@Param("ids") Collection<String> ids);


}
